import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import DiscoverFind from '../views/DiscoverFind.vue'
import ClassRoom from '../views/ClassRoom.vue'
import MyRoom from '../views/MyRoom.vue'
// import CompileChose from '../views/CompileChose.vue'
// import HotTop from '../views/HotTop.vue'
// import StoryShort from '../views/StoryShort.vue'
import RecommendPage from '../views/RecommendPage.vue'
import VideoClassify from '../views/VideoClassify.vue'
import UserPage from '../views/UserPage.vue'
import TakeNoteList from '../views/TakeNoteList.vue'
import ProductionList from '../views/ProductionList.vue'
import ViewDiscoverySearch from '../views/ViewDiscoverySearch.vue'
import CreatorList from '../views/CreatorList.vue'

Vue.use(VueRouter)
    //获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
    //修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [

    {
        path: '/',
        redirect: '/home/recommend',
        meta: {
            showNav: true
        },
    },
    {
        path: '/home',
        component: HomeView,
        meta: {
            showNav: true
        },

        children: [{
                path: '',
                redirect: '/home/recommend',
                meta: {
                    showNav: true
                },
            },
            {

                path: ':id',
                component: RecommendPage,
                meta: {
                    showNav: true
                },
            },



        ]
    },
    {
        path: '/take',
        name: 'take',
        meta: {
            showNav: true
        },
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
            import ( /* webpackChunkName: "about" */ '../views/TakeNotesOneself .vue')
    },
    {
        path: '/find',
        name: 'find',
        meta: {
            showNav: true
        },
        component: DiscoverFind
    },
    {
        path: '/classroom',
        name: 'classroom',
        meta: {
            showNav: true
        },
        component: ClassRoom
    },
    {
        path: '/mine',
        name: 'mine',
        meta: {
            showNav: true
        },
        component: MyRoom
    },

    // {
    //     path: '/home/classify',
    //     component: VideoClassify
    // },
    {
        path: '/classify',
        component: VideoClassify
    },
    {
        path: '/user',
        component: UserPage
    },
    {
        path: '/note',
        component: TakeNoteList
    },
    {
        path: '/works',
        component: ProductionList
    },
    {
        path: '/viewdiscovery',
        component: ViewDiscoverySearch
    },
    {
        path: '/creator',
        component: CreatorList
    },
]

const router = new VueRouter({
    routes
})

export default router